<?php

namespace Proxy;

include_once "SubjectInterface.php";
include_once "RealSubject.php";

/** 代理模式---代理类 */
class ProxySubject implements SubjectInterface
{
    /** 存放实体类的实例 */
    private  $realSubject;
    private string $fileName;
    public function __construct($params)
    {
        $this->fileName = $params;
    }

    /**
     * 代理请求
     * @return void
     */
    public function request()
    {
        if (is_null($this->realSubject)) {
            $this->realSubject = new RealSubject($this->fileName);
        }
        echo "代理模式---我是代理请求：{$this->fileName}" . PHP_EOL;
        $this->realSubject->request();
    }
}